
#pragma once

#include <cstdint>
#include <functional>

#include "../../MathLib/DXMath3.03fix/FlameMath.h"
#include "../../CommonLib/src/InputAction.h"
#include "SystemMessage.h"

namespace FlameEngine
{
	enum WindowState :uint8_t
	{
		ws_normal = 0,
		ws_minimized,
		ws_maxmized,
		ws_fullscreen,
	};

	enum WindowStyleFlag
	{
		wsf_default = 0x000,
		wsf_showTitlebar = 0x001,
		wsf_fullscreen = 0x002,
		wsf_showMinimizeBox = 0x004,
		wsf_showMaxmizeBox = 0x008,
	};

	struct WindowDesc
	{
		WindowStyleFlag style;
		int32_t posX;
		int32_t posY;
		uint32_t clientWidth;
		uint32_t clientHeight;
		uint32_t minClientWidth;
		uint32_t minClientHeight;
		std::string titleName;
		std::string appName;
		bool allowUserResize;
	};


	typedef std::function<void (InputAction&)> InputActionCallback;
	typedef std::function<void (SystemMessage msg)> SystemMessageCallback;
	typedef std::function<void ()> HostIdleCallback;
	class CreateWndCmd;

	class IRenderWindow
	{
	public:
		IRenderWindow(){};
		virtual ~IRenderWindow(){};

		virtual void CreateAndRun(CreateWndCmd* pWndCmd) = 0;
		virtual void Close() = 0;

		virtual void SetWindowPosition(const Int2& position) = 0;
		virtual const Int2& GetWindowPosition()const = 0;

		virtual void SetClientSize(const Int2& size) = 0;
		virtual const Int2& GetClientSize() const = 0;
		
		virtual void SetMinClientSize(const Int2& size) = 0;
		virtual const Int2& GetMinClientSize() const = 0;
		
		virtual const Int2& GetWindowSize() const = 0;
		virtual const Int2 GetMonitorResolution() const = 0;
		
		virtual void SetTitle(const std::string& title) = 0;
		virtual const std::string& GetTitle() const = 0;

		virtual void SetWindowState(WindowState ws) = 0;
		virtual WindowState GetWindowState() const = 0;
		
		virtual uint32_t GetWndHandle() = 0;

		virtual bool IsAllowUserResize() const = 0;
		virtual void SetAllowUserResize(bool enable) = 0;

		virtual void SetInputActionCallback(InputActionCallback& pCallback) = 0;
		virtual void SetSystemMessageCallback(SystemMessageCallback& pCallback) = 0;
		virtual void SetOnHostIdleCallback(HostIdleCallback& pCallback) = 0;

	private:
		IRenderWindow(const IRenderWindow&);
		IRenderWindow(const IRenderWindow&&);
		IRenderWindow& operator=(const IRenderWindow&);
	};
}